<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>循环遍历作业</title>
		
		<!-- 定义样式 -->
		<style>
			.red {
				color: red;
				font-size: 20px;
			}
		</style>
	</head>
	<body>
		<div id="app">
			<h3>题目说明: 当鼠标移动到哪里,哪里的颜色变成红色</h3>
			<h2>实现思路: 当鼠标的index与遍历的index一致时引用样式</h2>
			<ul >
				<li v-for="(name,index) in names" :class="{red:index==nowIndex}" @mouseleave="clickLi(index)">{{name}}</li>
			</ul>
		</div>	
		
		
		<script src="../js/vue.min.js"></script>
		<script type="text/javascript">
			const app = new Vue({
				
				el : "#app",
				data : {
					names: ["诺克萨斯之手","沙漠死神","邪恶小法师"],
					nowIndex: 0
				},
				methods: {
					clickLi(index){
						this.nowIndex = index;
					}
				}
			}) 
		</script>
	</body>
</html>
